import request from '@/utils/request'

const baseUrl = '/system'

/**
 * 查询系统部门列表
 * @param query 查询条件
 * @returns 
 */
export function getPageList(queryParams: SysDeptQuery, pageParams: PageParams) {
  return request({
    url: `${baseUrl}/depts`,
    method: 'get',
    params: { ...queryParams, ...pageParams },
  })
}

/**
 * 新增部门
 * @returns 
 */
export function add(data: SysDeptType) {
  return request({
    url: `${baseUrl}/depts`,
    method: 'post',
    data,
  });
}

/**
* 修改菜单
* @returns 
*/
export function update(data: SysDeptType) {
  return request({
    url: `${baseUrl}/depts/${data.id}/`,
    method: 'put',
    data,
  });
}

/**
 * 删除
 */
export function deleteById(id: string) {
  return request({
    url: `${baseUrl}/depts/${id}/`,
    method: 'delete',
  })
}

/**
 * 获取部门树
 */
export function getDeptSelect(pageParams: PageParams) {
  return request({
    url: `${baseUrl}/depts/tree`,
    method: 'get',
    params: pageParams,
  })
}